Skip to content

add instrumentation.provider to newrelic default attrs #2900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 24 additions & 20 deletions exporter/newrelicexporter/newrelic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ func TestExportTraceDataMinimum(t *testing.T) {
ID: "0000000000000001",
TraceID: "01010101010101010101010101010101",
Attributes: map[string]interface{}{
"collector.name": name,
"collector.version": version,
"name": "root",
"collector.name": name,
"collector.version": version,
"name": "root",
instrumentationProviderAttrKey: "opentelemetry",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would stick with string to make the test easier to read without having to double check against the code. Otherwise, let's update the other keys to use the variables - mixing strings and variables looks a bit odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I'll revert the key to string.

},
},
}
Expand Down Expand Up @@ -260,35 +261,38 @@ func TestExportTraceDataFullTrace(t *testing.T) {
ID: "0000000000000001",
TraceID: "01010101010101010101010101010101",
Attributes: map[string]interface{}{
"collector.name": name,
"collector.version": version,
"name": "root",
"resource": "R1",
"service.name": "test-service",
"collector.name": name,
"collector.version": version,
"name": "root",
"resource": "R1",
"service.name": "test-service",
instrumentationProviderAttrKey: "opentelemetry",
},
},
{
ID: "0000000000000002",
TraceID: "01010101010101010101010101010101",
Attributes: map[string]interface{}{
"collector.name": name,
"collector.version": version,
"name": "client",
"parent.id": "0000000000000001",
"resource": "R1",
"service.name": "test-service",
"collector.name": name,
"collector.version": version,
"name": "client",
"parent.id": "0000000000000001",
"resource": "R1",
"service.name": "test-service",
instrumentationProviderAttrKey: "opentelemetry",
},
},
{
ID: "0000000000000003",
TraceID: "01010101010101010101010101010101",
Attributes: map[string]interface{}{
"collector.name": name,
"collector.version": version,
"name": "server",
"parent.id": "0000000000000002",
"resource": "R1",
"service.name": "test-service",
"collector.name": name,
"collector.version": version,
"name": "server",
"parent.id": "0000000000000002",
"resource": "R1",
"service.name": "test-service",
instrumentationProviderAttrKey: "opentelemetry",
},
},
}
Expand Down
22 changes: 12 additions & 10 deletions exporter/newrelicexporter/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ import (
)

const (
unitAttrKey = "unit"
descriptionAttrKey = "description"
collectorNameKey = "collector.name"
collectorVersionKey = "collector.version"
instrumentationNameKey = "instrumentation.name"
instrumentationVersionKey = "instrumentation.version"
statusCodeKey = "otel.status_code"
statusDescriptionKey = "otel.status_description"
spanKindKey = "span.kind"
serviceNameKey = "service.name"
unitAttrKey = "unit"
descriptionAttrKey = "description"
collectorNameKey = "collector.name"
collectorVersionKey = "collector.version"
instrumentationNameKey = "instrumentation.name"
instrumentationVersionKey = "instrumentation.version"
instrumentationProviderAttrKey = "instrumentation.provider"
statusCodeKey = "otel.status_code"
statusDescriptionKey = "otel.status_description"
spanKindKey = "span.kind"
serviceNameKey = "service.name"
)

// TODO (MrAlias): unify this with the traceTransformer when the metric data
Expand Down Expand Up @@ -148,6 +149,7 @@ func (t *traceTransformer) SpanAttributes(span pdata.Span) map[string]interface{
// (overrides any existing)
attrs[collectorNameKey] = name
attrs[collectorVersionKey] = version
attrs[instrumentationProviderAttrKey] = "opentelemetry"

return attrs
}
Expand Down
1 change: 1 addition & 0 deletions exporter/newrelicexporter/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func defaultAttrFunc(res map[string]interface{}) func(map[string]interface{}) ma
full := make(map[string]interface{}, 2+len(res)+len(add))
full[collectorNameKey] = name
full[collectorVersionKey] = version
full[instrumentationProviderAttrKey] = "opentelemetry"
for k, v := range res {
full[k] = v
}
Expand Down