Update zipkin attribute names to match the spec. (#1693)

* Update zipkin attribute names to match the spec.

* remove out of date comment.
This commit is contained in:
John Watson 2020-09-23 18:28:44 -07:00 committed by GitHub
parent d9bd619b55
commit 8157af01a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -81,12 +81,8 @@ public final class ZipkinSpanExporter implements SpanExporter {
private static final Logger logger = Logger.getLogger(ZipkinSpanExporter.class.getName());
// The naming follows Zipkin convention. For http see here:
// https://github.com/openzipkin/brave/blob/eee993f998ae57b08644cc357a6d478827428710/instrumentation/http/src/main/java/brave/http/HttpTags.java
// For discussion about GRPC errors/tags, see here: https://github.com/openzipkin/brave/pull/999
// Note: these 3 fields are non-private for testing
static final String GRPC_STATUS_CODE = "grpc.status_code";
static final String GRPC_STATUS_DESCRIPTION = "grpc.status_description";
static final String OTEL_STATUS_CODE = "otel.status_code";
static final String OTEL_STATUS_DESCRIPTION = "otel.status_description";
static final AttributeKey<String> STATUS_ERROR = stringKey("error");
static final String KEY_INSTRUMENTATION_LIBRARY_NAME = "otel.instrumentation_library.name";
@ -159,9 +155,9 @@ public final class ZipkinSpanExporter implements SpanExporter {
Status status = spanData.getStatus();
// for GRPC spans, include status code & description.
if (status != null && spanAttributes.get(SemanticAttributes.RPC_SERVICE) != null) {
spanBuilder.putTag(GRPC_STATUS_CODE, status.getCanonicalCode().toString());
spanBuilder.putTag(OTEL_STATUS_CODE, status.getCanonicalCode().toString());
if (status.getDescription() != null) {
spanBuilder.putTag(GRPC_STATUS_DESCRIPTION, status.getDescription());
spanBuilder.putTag(OTEL_STATUS_DESCRIPTION, status.getDescription());
}
}
// add the error tag, if it isn't already in the source span.

View File

@ -226,9 +226,9 @@ class ZipkinSpanExporterTest {
.isEqualTo(
buildZipkinSpan(Span.Kind.SERVER)
.toBuilder()
.putTag(ZipkinSpanExporter.GRPC_STATUS_DESCRIPTION, errorMessage)
.putTag(ZipkinSpanExporter.OTEL_STATUS_DESCRIPTION, errorMessage)
.putTag(SemanticAttributes.RPC_SERVICE.getKey(), "my service name")
.putTag(ZipkinSpanExporter.GRPC_STATUS_CODE, "DEADLINE_EXCEEDED")
.putTag(ZipkinSpanExporter.OTEL_STATUS_CODE, "DEADLINE_EXCEEDED")
.putTag(ZipkinSpanExporter.STATUS_ERROR.getKey(), "DEADLINE_EXCEEDED")
.build());
}