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

Add AWS instrumentation for DynamoDB and disable HTTP instrumentation for Sentry requests #1758

Merged
merged 3 commits into from
Mar 6, 2025
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
5 changes: 5 additions & 0 deletions .changeset/little-bottles-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/apps-otel": minor
---

Properly disable HTTP instrumentation for Sentry requests. Added `AwsInstrumentation` factory that can be used to auto instrument DynamoDB calls.
6 changes: 6 additions & 0 deletions .changeset/lovely-zoos-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"saleor-app-segment": patch
"saleor-app-avatax": patch
---

Use `AwsInstrumentation` to auto instrument DynamoDB calls
3 changes: 2 additions & 1 deletion apps/avatax/src/instrumentations/otel-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
import { ATTR_DEPLOYMENT_ENVIRONMENT_NAME } from "@opentelemetry/semantic-conventions/incubating";
import { createAwsInstrumentation } from "@saleor/apps-otel/src/aws-instrumentation-factory";

Check warning on line 3 in apps/avatax/src/instrumentations/otel-node.ts

View check run for this annotation

Codecov / codecov/patch

apps/avatax/src/instrumentations/otel-node.ts#L3

Added line #L3 was not covered by tests
import { createBatchSpanProcessor } from "@saleor/apps-otel/src/batch-span-processor-factory";
import { createHttpInstrumentation } from "@saleor/apps-otel/src/http-instrumentation-factory";
import { registerOTel } from "@vercel/otel";
Expand All @@ -23,5 +24,5 @@
accessToken: env.OTEL_ACCESS_TOKEN,
}),
],
instrumentations: [createHttpInstrumentation()],
instrumentations: [createAwsInstrumentation(), createHttpInstrumentation()],

Check warning on line 27 in apps/avatax/src/instrumentations/otel-node.ts

View check run for this annotation

Codecov / codecov/patch

apps/avatax/src/instrumentations/otel-node.ts#L27

Added line #L27 was not covered by tests
});
3 changes: 2 additions & 1 deletion apps/segment/src/instrumentations/otel-node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ATTR_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
import { ATTR_DEPLOYMENT_ENVIRONMENT_NAME } from "@opentelemetry/semantic-conventions/incubating";
import { createAwsInstrumentation } from "@saleor/apps-otel/src/aws-instrumentation-factory";

Check warning on line 3 in apps/segment/src/instrumentations/otel-node.ts

View check run for this annotation

Codecov / codecov/patch

apps/segment/src/instrumentations/otel-node.ts#L3

Added line #L3 was not covered by tests
import { createBatchSpanProcessor } from "@saleor/apps-otel/src/batch-span-processor-factory";
import { createHttpInstrumentation } from "@saleor/apps-otel/src/http-instrumentation-factory";
import { registerOTel } from "@vercel/otel";
Expand All @@ -23,5 +24,5 @@
accessToken: env.OTEL_ACCESS_TOKEN,
}),
],
instrumentations: [createHttpInstrumentation()],
instrumentations: [createAwsInstrumentation(), createHttpInstrumentation()],

Check warning on line 27 in apps/segment/src/instrumentations/otel-node.ts

View check run for this annotation

Codecov / codecov/patch

apps/segment/src/instrumentations/otel-node.ts#L27

Added line #L27 was not covered by tests
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@opentelemetry/api-logs": "0.57.2",
"@opentelemetry/instrumentation": "0.57.2",
"@opentelemetry/instrumentation-http": "0.57.2",
"@opentelemetry/instrumentation-aws-sdk": "0.49.1",
"@opentelemetry/sdk-logs": "0.57.2",
"@opentelemetry/exporter-trace-otlp-http": "0.57.2",
"@opentelemetry/sdk-trace-node": "1.30.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/otel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"@opentelemetry/semantic-conventions": "../../node_modules/@opentelemetry/semantic-conventions",
"@opentelemetry/sdk-trace-node": "../../node_modules/@opentelemetry/sdk-trace-node",
"@opentelemetry/exporter-trace-otlp-http": "../../node_modules/@opentelemetry/exporter-trace-otlp-http",
"@opentelemetry/instrumentation-http": "../../node_modules/@opentelemetry/instrumentation-http",
"@opentelemetry/instrumentation-aws-sdk": "../../node_modules/@opentelemetry/instrumentation-aws-sdk",
"urql": "4.0.4",
"@saleor/app-sdk": "link:../../node_modules/@saleor/app-sdk"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/otel/src/aws-instrumentation-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { AwsInstrumentation } from "@opentelemetry/instrumentation-aws-sdk";

export const createAwsInstrumentation = () => {
return new AwsInstrumentation({
suppressInternalInstrumentation: true,
Copy link
Member

Choose a reason for hiding this comment

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

what does it mean? can you add comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 3691b21 (#1758)

});
};
3 changes: 1 addition & 2 deletions packages/otel/src/http-instrumentation-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
return new HttpInstrumentation({
requireParentforIncomingSpans: true,
requireParentforOutgoingSpans: true,
ignoreOutgoingRequestHook: (request) =>
request.hostname === "ingest.sentry.io" || request.path === "/v1/logs",
Copy link
Member Author

Choose a reason for hiding this comment

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

we no longer use logs from OTEL and integration already disables calls to v1/traces / v1/metrics etc

ignoreOutgoingRequestHook: (request) => request.hostname?.includes("ingest.sentry.io") ?? false,
});
};
4 changes: 3 additions & 1 deletion packages/otel/src/otel-urql-exchange-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { context, Span, SpanKind, SpanStatusCode, Tracer } from "@opentelemetry/
import { ATTR_URL_FULL } from "@opentelemetry/semantic-conventions/incubating";
import { type CombinedError, makeOperation, mapExchange, Operation } from "urql";

import { ObservabilityAttributes } from "./observability-attributes";

type Definition = {
name: {
value: string;
Expand Down Expand Up @@ -54,7 +56,7 @@ export const createOtelUrqlExchange = (args: { tracer: Tracer }) => {

span.setAttribute(GraphQLAttributeNames.OPERATION_KEY, operation.key);

span.setAttribute("saleorApiUrl", operation.context.url);
span.setAttribute(ObservabilityAttributes.SALEOR_API_URL, operation.context.url);

span.setAttribute(ATTR_URL_FULL, operation.context.url);

Expand Down
35 changes: 35 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading