Skip to content

Commit

Permalink
fix(serverless): align span operations to new operations (#5890)
Browse files Browse the repository at this point in the history
Signed-off-by: Outsider <outsideris@gmail.com>
  • Loading branch information
outsideris committed Oct 6, 2022
1 parent 6bd07a6 commit c3b246c
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/serverless/src/awslambda.ts
Expand Up @@ -315,7 +315,7 @@ export function wrapHandler<TEvent, TResult>(

const transaction = hub.startTransaction({
name: context.functionName,
op: 'awslambda.handler',
op: 'function.aws.lambda',
...traceparentData,
metadata: {
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/awsservices.ts
Expand Up @@ -65,7 +65,7 @@ function wrapMakeRequest<TService extends AWSService, TResult>(
if (transaction) {
span = transaction.startChild({
description: describe(this, operation, params),
op: 'aws.request',
op: 'http.client',
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/gcpfunction/cloud_events.ts
Expand Up @@ -34,7 +34,7 @@ function _wrapCloudEventFunction(

const transaction = hub.startTransaction({
name: context.type || '<unknown>',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
});

Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/gcpfunction/events.ts
Expand Up @@ -36,7 +36,7 @@ function _wrapEventFunction<F extends EventFunction | EventFunctionWithCallback>

const transaction = hub.startTransaction({
name: context.eventType,
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
});

Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/gcpfunction/http.ts
Expand Up @@ -85,7 +85,7 @@ function _wrapHttpFunction(fn: HttpFunction, wrapOptions: Partial<HttpFunctionWr

const transaction = hub.startTransaction({
name: `${reqMethod} ${reqUrl}`,
op: 'gcp.function.http',
op: 'function.gcp.http',
...traceparentData,
metadata: {
dynamicSamplingContext: traceparentData && !dynamicSamplingContext ? {} : dynamicSamplingContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/google-cloud-grpc.ts
Expand Up @@ -114,7 +114,7 @@ function fillGrpcFunction(stub: Stub, serviceIdentifier: string, methodName: str
if (transaction) {
span = transaction.startChild({
description: `${callType} ${methodName}`,
op: `gcloud.grpc.${serviceIdentifier}`,
op: `grpc.${serviceIdentifier}`,
});
}
ret.on('status', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/google-cloud-http.ts
Expand Up @@ -59,7 +59,7 @@ function wrapRequestFunction(orig: RequestFunction): RequestFunction {
const httpMethod = reqOpts.method || 'GET';
span = transaction.startChild({
description: `${httpMethod} ${reqOpts.uri}`,
op: `gcloud.http.${identifyService(this.apiEndpoint)}`,
op: `http.client.${identifyService(this.apiEndpoint)}`,
});
}
orig.call(this, reqOpts, (...args: Parameters<ResponseCallback>) => {
Expand Down
16 changes: 8 additions & 8 deletions packages/serverless/test/awslambda.test.ts
Expand Up @@ -191,7 +191,7 @@ describe('AWSLambda', () => {

const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand All @@ -218,7 +218,7 @@ describe('AWSLambda', () => {
} catch (e) {
const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand Down Expand Up @@ -258,7 +258,7 @@ describe('AWSLambda', () => {
expect.objectContaining({
parentSpanId: '1121201211212012',
parentSampled: false,
op: 'awslambda.handler',
op: 'function.aws.lambda',
name: 'functionName',
traceId: '12312012123120121231201212312012',
metadata: {
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('AWSLambda', () => {
} catch (e) {
const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
traceId: '12312012123120121231201212312012',
parentSpanId: '1121201211212012',
parentSampled: false,
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('AWSLambda', () => {

const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand Down Expand Up @@ -360,7 +360,7 @@ describe('AWSLambda', () => {
} catch (e) {
const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand Down Expand Up @@ -402,7 +402,7 @@ describe('AWSLambda', () => {

const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand Down Expand Up @@ -440,7 +440,7 @@ describe('AWSLambda', () => {
} catch (e) {
const fakeTransactionContext = {
name: 'functionName',
op: 'awslambda.handler',
op: 'function.aws.lambda',
metadata: { source: 'component' },
};

Expand Down
6 changes: 3 additions & 3 deletions packages/serverless/test/awsservices.test.ts
Expand Up @@ -32,7 +32,7 @@ describe('AWSServices', () => {
expect(data.Body?.toString('utf-8')).toEqual('contents');
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'aws.request',
op: 'http.client',
description: 'aws.s3.getObject foo',
});
// @ts-ignore see "Why @ts-ignore" note
Expand All @@ -49,7 +49,7 @@ describe('AWSServices', () => {
});
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'aws.request',
op: 'http.client',
description: 'aws.s3.getObject foo',
});
});
Expand All @@ -64,7 +64,7 @@ describe('AWSServices', () => {
expect(data.Payload?.toString('utf-8')).toEqual('reply');
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'aws.request',
op: 'http.client',
description: 'aws.lambda.invoke foo',
});
});
Expand Down
30 changes: 15 additions & 15 deletions packages/serverless/test/gcpfunction.test.ts
Expand Up @@ -113,7 +113,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'POST /path',
op: 'gcp.function.http',
op: 'function.gcp.http',
metadata: { source: 'route' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'POST /path',
op: 'gcp.function.http',
op: 'function.gcp.http',
traceId: '12312012123120121231201212312012',
parentSpanId: '1121201211212012',
parentSampled: false,
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'POST /path',
op: 'gcp.function.http',
op: 'function.gcp.http',
traceId: '12312012123120121231201212312012',
parentSpanId: '1121201211212012',
parentSampled: false,
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand All @@ -288,7 +288,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -380,7 +380,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand All @@ -407,7 +407,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.event',
op: 'function.gcp.event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand All @@ -501,7 +501,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -530,7 +530,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand All @@ -557,7 +557,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down Expand Up @@ -585,7 +585,7 @@ describe('GCPFunction', () => {

const fakeTransactionContext = {
name: 'event.type',
op: 'gcp.function.cloud_event',
op: 'function.gcp.cloud_event',
metadata: { source: 'component' },
};
// @ts-ignore see "Why @ts-ignore" note
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/test/google-cloud-grpc.test.ts
Expand Up @@ -128,7 +128,7 @@ describe('GoogleCloudGrpc tracing', () => {
expect(resp).toEqual('1637084156623860');
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'gcloud.grpc.pubsub',
op: 'grpc.pubsub',
description: 'unary call publish',
});
await pubsub.close();
Expand Down
4 changes: 2 additions & 2 deletions packages/serverless/test/google-cloud-http.test.ts
Expand Up @@ -59,12 +59,12 @@ describe('GoogleCloudHttp tracing', () => {
expect(resp).toEqual([[{ foo: true }]]);
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'gcloud.http.bigquery',
op: 'http.client.bigquery',
description: 'POST /jobs',
});
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
op: 'gcloud.http.bigquery',
op: 'http.client.bigquery',
description: expect.stringMatching(new RegExp('^GET /queries/.+')),
});
});
Expand Down

0 comments on commit c3b246c

Please sign in to comment.