Skip to content
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

feat(sdk-trace-base): add dropped attributes and events count on span #3576

Merged
merged 36 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b2c9f40
feat(sdk-trace-base): add dropped attributes and events count on span
mohitk05 Jan 27, 2023
55a26b8
feat(sdk-trace-base): sync with main
mohitk05 Jan 27, 2023
b3e0307
feat(sdk-trace-base): [revert] sync with main
mohitk05 Jan 27, 2023
842143d
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Jan 27, 2023
bab88a1
feat(sdk-trace-base): fix tests, make both counts truthy
mohitk05 Jan 28, 2023
33378f8
Merge branch 'feat/span-dropped-counts' of github.com:mohitk05/opente…
mohitk05 Jan 28, 2023
28666c6
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Jan 30, 2023
17213bd
feat(sdk-trace-base): Update dropped counts type to number
mohitk05 Jan 31, 2023
81e35f6
Merge branch 'open-telemetry:main' into feat/span-dropped-counts
mohitk05 Jan 31, 2023
4eb895c
feat(sdk-trace-base): Merge branch 'feat/span-dropped-counts' of gith…
mohitk05 Jan 31, 2023
a8c1454
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Feb 1, 2023
dc78fa3
feat(sdk-trace-base): Use exposed counts on ReadableSpan in jaeger an…
mohitk05 Feb 5, 2023
08d75e4
feat(sdk-trace-base): Merge branch 'feat/span-dropped-counts' of gith…
mohitk05 Feb 5, 2023
4a3105e
Merge branch 'main' into feat/span-dropped-counts
dyladan Feb 9, 2023
411c1cb
feat(sdk-trace-base): WIP - revert tsconfig, add new attribute limits
mohitk05 Feb 9, 2023
32300bf
feat(sdk-trace-base): Update attribute truncate method
mohitk05 Feb 9, 2023
5439f4e
Merge branch 'main' into feat/span-dropped-counts
dyladan Feb 24, 2023
0365435
Fix bad conflict resolution
dyladan Feb 24, 2023
8a486c7
Remove unused import
dyladan Feb 24, 2023
f9d935c
chore: lint
dyladan Feb 24, 2023
036190f
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Feb 28, 2023
18d82c6
feat(sdk-trace-base): Remove dropped event attributes logic, add Jaeg…
mohitk05 Feb 28, 2023
f674906
feat(sdk-trace-base): Undo formatting in changelog
mohitk05 Feb 28, 2023
577b174
fix(changelog): Update experimental changelog
mohitk05 Feb 28, 2023
6dadccb
Update packages/opentelemetry-sdk-trace-base/src/Span.ts
mohitk05 Mar 1, 2023
1748267
Update packages/opentelemetry-sdk-trace-base/src/Span.ts
mohitk05 Mar 1, 2023
cc632ef
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 1, 2023
69b407f
fix(sdk-trace-base): Resolve review comments
mohitk05 Mar 1, 2023
85b2038
Merge branch 'main' into feat/span-dropped-counts
Flarna Mar 1, 2023
f260436
fix(sdk-trace-base): Fix failing tests
mohitk05 Mar 1, 2023
1db099c
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 1, 2023
0239413
fix(sdk-trace-base): make droppedAttributesCount on event optional
mohitk05 Mar 2, 2023
f40a11b
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 2, 2023
60bc89f
Merge branch 'main' into feat/span-dropped-counts
Flarna Mar 3, 2023
141172e
Merge branch 'main' into feat/span-dropped-counts
mohitk05 Mar 7, 2023
2221770
fix(changelog): Update changelog files
mohitk05 Mar 7, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureExportedEventsAreCorrect(events: IEvent[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export const mockedResources: Resource[] = [
Expand Down Expand Up @@ -142,6 +145,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8885000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
{
name: 'span2',
Expand All @@ -164,6 +170,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8775000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
{
name: 'span3',
Expand All @@ -186,6 +195,9 @@ export const basicTrace: ReadableSpan[] = [
duration: [0, 8775000],
resource: mockedResources[0],
instrumentationLibrary: mockedInstrumentationLibraries[0],
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ export const mockedReadableSpan: ReadableSpan = {
cost: 112.12,
}),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureProtoEventsAreCorrect(events: IEvent[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export const mockedReadableSpan: ReadableSpan = {
})
),
instrumentationLibrary: { name: 'default', version: '0.0.1' },
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

export function ensureExportedEventsAreCorrect(events: IEvent[]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"extends": "../../../tsconfig.base.esnext.json",
"compilerOptions": {
"allowJs": true,
dyladan marked this conversation as resolved.
Show resolved Hide resolved
"outDir": "build/esnext",
"rootDir": "src",
"outDir": "build/esnext",
"tsBuildInfoFile": "build/esnext/tsconfig.esnext.tsbuildinfo"
},
"include": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ export function sdkSpanToOtlpSpan(span: ReadableSpan, useHex?: boolean): ISpan {
startTimeUnixNano: hrTimeToNanoseconds(span.startTime),
endTimeUnixNano: hrTimeToNanoseconds(span.endTime),
attributes: toAttributes(span.attributes),
droppedAttributesCount: 0,
droppedAttributesCount: span.droppedAttributesCount,
events: span.events.map(toOtlpSpanEvent),
droppedEventsCount: 0,
droppedEventsCount: span.droppedEventsCount,
status: {
// API and proto enums share the same values
code: status.code as unknown as EStatusCode,
message: status.message,
},
links: span.links.map(link => toOtlpLink(link, useHex)),
droppedLinksCount: 0,
droppedLinksCount: span.droppedLinksCount,
};
}

Expand Down
3 changes: 3 additions & 0 deletions experimental/packages/otlp-transformer/test/trace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ describe('Trace', () => {
status: {
code: SpanStatusCode.OK,
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};
});

Expand Down
24 changes: 24 additions & 0 deletions packages/opentelemetry-exporter-jaeger/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@ export function spanToThrift(span: ReadableSpan): ThriftSpan {
});
}

/* Add droppedAttributesCount as a tag */
if (span.droppedAttributesCount) {
tags.push({
key: 'otel.dropped_attributes_count',
value: toTagValue(span.droppedAttributesCount),
});
}

/* Add droppedEventsCount as a tag */
if (span.droppedEventsCount) {
tags.push({
key: 'otel.dropped_events_count',
value: toTagValue(span.droppedEventsCount),
});
}
dyladan marked this conversation as resolved.
Show resolved Hide resolved

/* Add droppedLinksCount as a tag */
if (span.droppedLinksCount) {
tags.push({
key: 'otel.dropped_links_count',
value: toTagValue(span.droppedLinksCount),
});
}
dyladan marked this conversation as resolved.
Show resolved Hide resolved

const spanTags: ThriftTag[] = ThriftUtils.getThriftTags(tags);

const logs = span.events.map((event): Log => {
Expand Down
3 changes: 3 additions & 0 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ describe('JaegerExporter', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};
describe('constructor', () => {
afterEach(() => {
Expand Down
15 changes: 15 additions & 0 deletions packages/opentelemetry-exporter-jaeger/test/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ describe('transform', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

const thriftSpan = spanToThrift(readableSpan);
Expand Down Expand Up @@ -179,6 +182,9 @@ describe('transform', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

const thriftSpan = spanToThrift(readableSpan);
Expand Down Expand Up @@ -246,6 +252,9 @@ describe('transform', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

const thriftSpan = spanToThrift(readableSpan);
Expand Down Expand Up @@ -291,6 +300,9 @@ describe('transform', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};

const thriftSpan = spanToThrift(readableSpan);
Expand Down Expand Up @@ -353,6 +365,9 @@ describe('transform', () => {
name: 'default',
version: '0.0.1',
},
droppedAttributesCount: 0,
droppedEventsCount: 0,
droppedLinksCount: 0,
};
let thriftSpan = spanToThrift(readableSpan);
assert.strictEqual(
Expand Down
38 changes: 25 additions & 13 deletions packages/opentelemetry-exporter-zipkin/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as api from '@opentelemetry/api';
import { ReadableSpan, TimedEvent } from '@opentelemetry/sdk-trace-base';
import { hrTimeToMicroseconds } from '@opentelemetry/core';
import * as zipkinTypes from './types';
import { Resource } from '@opentelemetry/resources';

const ZIPKIN_SPAN_KIND_MAPPING = {
[api.SpanKind.CLIENT]: zipkinTypes.SpanKind.CLIENT,
Expand Down Expand Up @@ -51,13 +50,7 @@ export function toZipkinSpan(
timestamp: hrTimeToMicroseconds(span.startTime),
duration: hrTimeToMicroseconds(span.duration),
localEndpoint: { serviceName },
tags: _toZipkinTags(
span.attributes,
span.status,
statusCodeTagName,
statusErrorTagName,
span.resource
),
tags: _toZipkinTags(span, statusCodeTagName, statusErrorTagName),
annotations: span.events.length
? _toZipkinAnnotations(span.events)
: undefined,
Expand All @@ -66,13 +59,18 @@ export function toZipkinSpan(
return zipkinSpan;
}

/** Converts OpenTelemetry SpanAttributes and SpanStatus to Zipkin Tags format. */
/** Converts OpenTelemetry Span properties to Zipkin Tags format. */
export function _toZipkinTags(
attributes: api.SpanAttributes,
status: api.SpanStatus,
{
attributes,
resource,
status,
droppedAttributesCount,
droppedEventsCount,
droppedLinksCount,
}: ReadableSpan,
statusCodeTagName: string,
statusErrorTagName: string,
resource: Resource
statusErrorTagName: string
): zipkinTypes.Tags {
const tags: { [key: string]: string } = {};
for (const key of Object.keys(attributes)) {
Expand All @@ -84,6 +82,20 @@ export function _toZipkinTags(
if (status.code === api.SpanStatusCode.ERROR && status.message) {
tags[statusErrorTagName] = status.message;
}
/* Add droppedAttributesCount as a tag */
if (droppedAttributesCount) {
tags['otel.dropped_attributes_count'] = String(droppedAttributesCount);
}

/* Add droppedEventsCount as a tag */
if (droppedEventsCount) {
tags['otel.dropped_events_count'] = String(droppedEventsCount);
}

/* Add droppedLinksCount as a tag */
if (droppedLinksCount) {
tags['otel.dropped_links_count'] = String(droppedLinksCount);
}

Object.keys(resource.attributes).forEach(
name => (tags[name] = String(resource.attributes[name]))
Expand Down
Loading