Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Broker tracing conventions #1064

Merged
merged 7 commits into from
May 19, 2020

Conversation

ian-mi
Copy link
Contributor

@ian-mi ian-mi commented May 13, 2020

Fixes #1063

Proposed Changes

Release Note

- 🎁 The GCP Broker now emits broker and trigger trace spans named broker:<name>.<namespace> and trigger:<name>.<namespace> respectively.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ian-mi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@googlebot googlebot added the cla: yes (override cla status due to multiple authors bug) label May 13, 2020
@ian-mi
Copy link
Contributor Author

ian-mi commented May 13, 2020

Manually verified to produce the expected spans in Stackdriver.

@ian-mi
Copy link
Contributor Author

ian-mi commented May 13, 2020

/hold needs fix for response spans

@ian-mi ian-mi force-pushed the broker-tracing-conventions branch from 21c7f57 to cafe654 Compare May 14, 2020 03:25
@Harwayne
Copy link
Contributor

/retest

pkg/broker/ingress/handler.go Outdated Show resolved Hide resolved
@@ -127,15 +136,26 @@ func (h *Handler) ServeHTTP(response nethttp.ResponseWriter, request *nethttp.Re

event.SetExtension(EventArrivalTime, cev2.Timestamp{Time: time.Now()})

ctx, span := trace.StartSpan(ctx, kntracing.BrokerMessagingDestination(broker))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check for an existing distributed trace? For example, if something has been replied back into the Broker. Or if the source that sent this already had started a trace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing trace context should always be set in the HTTP tracecontext so there is no need to check for the extension.

span.AddAttributes(
kntracing.MessagingSystemAttribute,
tracing.PubSubProtocolAttribute,
kntracing.BrokerMessagingDestinationAttribute(broker),
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this attribute represent?

For example, if this attribute is on a span, how can I interpret that span?

I ask because it looks like in the ingress we are annotating the span that sends the request to GCP PubSub with the broker as the destination. While in the filtering code I think the annotation states the trigger name while sending to the trigger's destination.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This attribute considers each broker or trigger to be an event destination. On ingress a single broker span will be created and on fanout multiple trigger spans will be created identifiable by the messaging.destination attribute as well as the span name.

span.AddAttributes(
kntracing.MessagingSystemAttribute,
tracing.PubSubProtocolAttribute,
kntracing.TriggerMessagingDestinationAttribute(trigger),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this include any form of type information? As-is, I can't tell the difference between different objects that have the same name and namespace (e.g. K8s service vs Broker vs KafkaChannel).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

messaging.destination is prefixed by either broker or trigger and will contain the namespaced name.

@ian-mi
Copy link
Contributor Author

ian-mi commented May 14, 2020

/unhold

Copy link
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

Holding in case @yolocs has any more comments.

Copy link
Member

@yolocs yolocs left a comment

Choose a reason for hiding this comment

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

/lgtm

Left a comment but feel free to unhold.

@ian-mi
Copy link
Contributor Author

ian-mi commented May 18, 2020

/unhold

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-google-knative-gcp-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/broker/handler/pool/providers.go Do not exist 66.7%
pkg/broker/handler/processors/filter/processor.go 78.6% 84.2% 5.6
pkg/broker/ingress/handler.go 71.4% 90.9% 19.5

Copy link
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

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

/lgtm

@yolocs
Copy link
Member

yolocs commented May 19, 2020

/lgtm

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

11 similar comments
@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@ian-mi
Copy link
Contributor Author

ian-mi commented May 19, 2020

/retest

@knative-prow-robot knative-prow-robot merged commit c3fad97 into google:master May 19, 2020
@ian-mi ian-mi deleted the broker-tracing-conventions branch May 19, 2020 21:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved cla: yes (override cla status due to multiple authors bug) lgtm size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GCP Broker Follows Eventing Conventions for Spans and Attributes.
6 participants