-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tracing conventions to broker spec * Add broker ingress spans with messaging span attributes * Add trigger span and messaging span attributes * Add test coverage of attributes.go It is possible to directly test the attribute helpers since attribute fields are unexported. * Format docs/spec/broker.md Co-authored-by: Matt Moore <[email protected]> * Format Markdown Co-authored-by: Matt Moore <[email protected]> Co-authored-by: Matt Moore <[email protected]>
- Loading branch information
Showing
8 changed files
with
222 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2020 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package tracing | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go.opencensus.io/trace" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
const ( | ||
MessagingSystemAttributeName = "messaging.system" | ||
MessagingDestinationAttributeName = "messaging.destination" | ||
MessagingProtocolAttributeName = "messaging.protocol" | ||
MessagingMessageIDAttributeName = "messaging.message_id" | ||
) | ||
|
||
var ( | ||
MessagingSystemAttribute trace.Attribute = trace.StringAttribute(MessagingSystemAttributeName, "knative") | ||
MessagingProtocolHTTP trace.Attribute = MessagingProtocolAttribute("HTTP") | ||
) | ||
|
||
func MessagingProtocolAttribute(protocol string) trace.Attribute { | ||
return trace.StringAttribute(MessagingProtocolAttributeName, protocol) | ||
} | ||
|
||
func MessagingMessageIDAttribute(ID string) trace.Attribute { | ||
return trace.StringAttribute(MessagingMessageIDAttributeName, ID) | ||
} | ||
|
||
func BrokerMessagingDestination(b types.NamespacedName) string { | ||
return fmt.Sprintf("broker:%s.%s", b.Name, b.Namespace) | ||
} | ||
func BrokerMessagingDestinationAttribute(b types.NamespacedName) trace.Attribute { | ||
return trace.StringAttribute(MessagingDestinationAttributeName, BrokerMessagingDestination(b)) | ||
} | ||
|
||
func TriggerMessagingDestination(t types.NamespacedName) string { | ||
return fmt.Sprintf("trigger:%s.%s", t.Name, t.Namespace) | ||
} | ||
|
||
func TriggerMessagingDestinationAttribute(t types.NamespacedName) trace.Attribute { | ||
return trace.StringAttribute(MessagingDestinationAttributeName, TriggerMessagingDestination(t)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright 2020 The Knative Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package tracing | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
func TestBrokerMessagingDestination(t *testing.T) { | ||
got := BrokerMessagingDestination(types.NamespacedName{ | ||
Namespace: "brokerns", | ||
Name: "brokername", | ||
}) | ||
want := "broker:brokername.brokerns" | ||
if want != got { | ||
t.Errorf("unexpected messaging destination: want %q, got %q", want, got) | ||
} | ||
} | ||
|
||
func TestTriggerMessagingDestination(t *testing.T) { | ||
got := TriggerMessagingDestination(types.NamespacedName{ | ||
Namespace: "triggerns", | ||
Name: "triggername", | ||
}) | ||
want := "trigger:triggername.triggerns" | ||
if want != got { | ||
t.Errorf("unexpected messaging destination: want %q, got %q", want, got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters