Skip to content

Commit

Permalink
Merge pull request #255 from vvydier/fix_env_vars
Browse files Browse the repository at this point in the history
fix env variables as per changes in the otel spec
Changed the env variable to OTEL_RESOURCE_ATTRIBUTES as per the spec https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable
Changing the environment variables to TRACEPARENT and TRACESTATE for inter-process propagation Environment Variables as Carrier for Inter-Process Propagation to transport context opentelemetry-specification#740
  • Loading branch information
Ignacio Bonafonte authored Oct 27, 2021
2 parents c7eb143 + a09e31b commit 1583678
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/OpenTelemetrySdk/Resources/EnvVarResource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import OpenTelemetryApi

/// Provides a framework for detection of resource information from the environment variable "OC_RESOURCE_LABELS".
public struct EnvVarResource {
private static let otelResourceAttributesEnv = "OTEL_RESOURCE_ATTRIBUTES_ENV"
private static let otelResourceAttributesEnv = "OTEL_RESOURCE_ATTRIBUTES"
private static let labelListSplitter = Character(",")
private static let labelKeyValueSplitter = Character("=")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import OpenTelemetryApi
*/

public struct EnvironmentContextPropagator: TextMapPropagator {
static let traceParent = "OTEL_TRACE_PARENT"
static let traceState = "OTEL_TRACE_STATE"
static let traceParent = "TRACEPARENT"
static let traceState = "TRACESTATE"
let w3cPropagator = W3CTraceContextPropagator()

public let fields: Set<String> = [traceState, traceParent]
Expand Down
4 changes: 2 additions & 2 deletions Tests/OpenTelemetrySdkTests/Trace/SpanBuilderSdkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class SpanBuilderSdkTest: XCTestCase {
}

func testParentEnvironmentContext() {
setenv("OTEL_TRACE_PARENT", "00-ff000000000000000000000000000041-ff00000000000041-01", 1)
setenv("TRACEPARENT", "00-ff000000000000000000000000000041-ff00000000000041-01", 1)
let providerWithEnv = TracerProviderSdk()
let tracerAux = providerWithEnv.get(instrumentationName: "SpanBuilderWithEnvTest")
let parent = tracerAux.spanBuilder(spanName: spanName).setNoParent().setActive(true).startSpan()
Expand All @@ -247,7 +247,7 @@ class SpanBuilderSdkTest: XCTestCase {
XCTAssertEqual(parent.context.traceId.hexString, "ff000000000000000000000000000041")
span.end()
parent.end()
unsetenv("OTEL_TRACE_PARENT")
unsetenv("TRACEPARENT")
}

func testParent_timestampConverter() {
Expand Down

0 comments on commit 1583678

Please sign in to comment.