Skip to content

Commit

Permalink
[contrib] add orchestrion integration configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMuller committed Jan 9, 2025
1 parent 7a7b85f commit 3094530
Show file tree
Hide file tree
Showing 53 changed files with 3,841 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/orchestrion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ concurrency:
cancel-in-progress: true

jobs:
generate:
name: Verify root orchestrion.yml file is up-to-date
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: stable
cache: true
- name: Run generator
run: go generate ./internal/orchestrion
- name: Check for changes
run: git diff --exit-code

test:
name: 'Run Tests'
uses: DataDog/orchestrion/.github/workflows/workflow_call.yml@main # we don't want to pin our own action
Expand Down
26 changes: 26 additions & 0 deletions contrib/99designs/gqlgen/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/99designs/gqlgen
description: gqlgen is a Go library for building GraphQL servers without any fuss.

aspects:
- id: New
join-point:
one-of:
- function-call: github.com/99designs/gqlgen/graphql/handler.New
- function-call: github.com/99designs/gqlgen/graphql/handler.NewDefaultServer
advice:
- wrap-expression:
imports:
handler: github.com/99designs/gqlgen/graphql/handler
gqlgentrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/99designs/gqlgen
template: |-
func(s *handler.Server) *handler.Server {
s.Use(gqlgentrace.NewTracer())
return s
}({{ . }})
80 changes: 80 additions & 0 deletions contrib/IBM/sarama.v1/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1
description: Sarama is a Go library for Apache Kafka

aspects:
- id: NewConsumer
join-point:
one-of:
- function-call: github.com/IBM/sarama.NewConsumer
- function-call: github.com/IBM/sarama.NewConsumerClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1
sarama: github.com/IBM/sarama
template: |-
func(c sarama.Consumer, err error) (sarama.Consumer, error) {
if c != nil {
c = saramatrace.WrapConsumer(c)
}
return c, err
}({{ . }})
- id: NewSyncProducer
join-point:
one-of:
- function-call: github.com/IBM/sarama.NewSyncProducer
- function-call: github.com/IBM/sarama.NewSyncProducerFromClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1
sarama: github.com/IBM/sarama
template: |-
{{- $cfg := .Function.ArgumentOfType "sarama.Config" -}}
func(p sarama.SyncProducer, err error) (sarama.SyncProducer, error) {
if p != nil {
p = saramatrace.WrapSyncProducer(
{{- if $cfg -}}
{{ $cfg }},
{{- else -}}
nil,
{{- end -}}
p,
)
}
return p, err
}({{ . }})
- id: NewAsyncProducer
join-point:
one-of:
- function-call: github.com/IBM/sarama.NewAsyncProducer
- function-call: github.com/IBM/sarama.NewAsyncProducerFromClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/IBM/sarama.v1
sarama: github.com/IBM/sarama
template: |-
{{- $cfg := .Function.ArgumentOfType "sarama.Config" -}}
func(p sarama.AsyncProducer, err error) (sarama.AsyncProducer, error) {
if p != nil {
p = saramatrace.WrapAsyncProducer(
{{- if $cfg -}}
{{ $cfg }},
{{- else -}}
nil,
{{- end -}}
p,
)
}
return p, err
}({{ . }})
80 changes: 80 additions & 0 deletions contrib/Shopify/sarama/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama
description: Sarama is a Go library for Apache Kafka

aspects:
- id: NewConsumer
join-point:
one-of:
- function-call: github.com/Shopify/sarama.NewConsumer
- function-call: github.com/Shopify/sarama.NewConsumerClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama
sarama: github.com/Shopify/sarama
template: |-
func(c sarama.Consumer, err error) (sarama.Consumer, error) {
if c != nil {
c = saramatrace.WrapConsumer(c)
}
return c, err
}({{ . }})
- id: NewSyncProducer
join-point:
one-of:
- function-call: github.com/Shopify/sarama.NewSyncProducer
- function-call: github.com/Shopify/sarama.NewSyncProducerFromClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama
sarama: github.com/Shopify/sarama
template: |-
{{- $cfg := .Function.ArgumentOfType "sarama.Config" -}}
func(p sarama.SyncProducer, err error) (sarama.SyncProducer, error) {
if p != nil {
p = saramatrace.WrapSyncProducer(
{{- if $cfg -}}
{{ $cfg }},
{{- else -}}
nil,
{{- end -}}
p,
)
}
return p, err
}({{ . }})
- id: NewAsyncProducer
join-point:
one-of:
- function-call: github.com/Shopify/sarama.NewAsyncProducer
- function-call: github.com/Shopify/sarama.NewAsyncProducerFromClient
advice:
- wrap-expression:
imports:
saramatrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/Shopify/sarama
sarama: github.com/Shopify/sarama
template: |-
{{- $cfg := .Function.ArgumentOfType "sarama.Config" -}}
func(p sarama.AsyncProducer, err error) (sarama.AsyncProducer, error) {
if p != nil {
p = saramatrace.WrapAsyncProducer(
{{- if $cfg -}}
{{ $cfg }},
{{- else -}}
nil,
{{- end -}}
p,
)
}
return p, err
}({{ . }})
44 changes: 44 additions & 0 deletions contrib/aws/aws-sdk-go-v2/aws/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go-v2/aws
description: The official AWS SDK for Go

aspects:
- id: Config
join-point:
struct-literal:
type: github.com/aws/aws-sdk-go-v2/aws.Config
match: value-only
advice:
- wrap-expression:
imports:
awstrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go-v2/aws
aws: github.com/aws/aws-sdk-go-v2/aws
template: |-
func(cfg aws.Config) (aws.Config) {
awstrace.AppendMiddleware(&cfg)
return cfg
}({{ . }})
- id: '*Config'
join-point:
one-of:
- struct-literal:
type: github.com/aws/aws-sdk-go-v2/aws.Config
match: pointer-only
- function-call: github.com/aws/aws-sdk-go-v2/aws.NewConfig
advice:
- wrap-expression:
imports:
awstrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go-v2/aws
aws: github.com/aws/aws-sdk-go-v2/aws
template: |-
func(cfg *aws.Config) (*aws.Config) {
awstrace.AppendMiddleware(cfg)
return cfg
}({{ . }})
27 changes: 27 additions & 0 deletions contrib/aws/aws-sdk-go/aws/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go/aws
description: The official AWS SDK for Go

aspects:
- id: session.NewSession
join-point:
function-call: github.com/aws/aws-sdk-go/aws/session.NewSession
advice:
- wrap-expression:
imports:
awstrace: gopkg.in/DataDog/dd-trace-go.v1/contrib/aws/aws-sdk-go/aws
session: github.com/aws/aws-sdk-go/aws/session
template: |-
func(sess *session.Session, err error) (*session.Session, error) {
if sess != nil {
sess = awstrace.WrapSession(sess)
}
return sess, err
}({{ . }})
103 changes: 103 additions & 0 deletions contrib/cloud.google.com/go/pubsub.v1/orchestrion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2023-present Datadog, Inc.
---
# yaml-language-server: $schema=https://datadoghq.dev/orchestrion/schema.json
meta:
name: gopkg.in/DataDog/dd-trace-go.v1/contrib/cloud.google.com/go/pubsub.v1
description: Package pubsub provides an easy way to publish and receive Google Cloud Pub/Sub messages, hiding the details of the underlying server RPCs

aspects:
## Trace Receive ##
- id: Subscription.Receive
join-point:
function-body:
function:
- receiver: '*cloud.google.com/go/pubsub.Subscription'
- name: Receive
advice:
- prepend-statements:
imports:
tracing: gopkg.in/DataDog/dd-trace-go.v1/contrib/cloud.google.com/go/pubsub.v1/internal/tracing
template: |-
{{- $subscription := .Function.Receiver -}}
{{- $handler := .Function.Argument 1 -}}
__dd_traceFn := tracing.TraceReceiveFunc({{ $subscription }})
__dd_wrapHandler := func(h func(ctx context.Context, msg *Message)) func(ctx context.Context, msg *Message) {
return func(ctx context.Context, msg *Message) {
__dd_traceMsg := &tracing.Message{
ID: msg.ID,
Data: msg.Data,
OrderingKey: msg.OrderingKey,
Attributes: msg.Attributes,
DeliveryAttempt: msg.DeliveryAttempt,
PublishTime: msg.PublishTime,
}
ctx, closeSpan := __dd_traceFn(ctx, __dd_traceMsg)
defer closeSpan()
h(ctx, msg)
}
}
{{ $handler }} = __dd_wrapHandler({{ $handler }})
## Trace Publish ##
- id: PublishResult
join-point:
struct-definition: cloud.google.com/go/internal/pubsub.PublishResult
advice:
- inject-declarations:
template: |-
type DDCloseSpanFunc = func(serverID string, err error)
- add-struct-field:
name: DDCloseSpan
type: DDCloseSpanFunc

- id: Topic.Publish
join-point:
function-body:
function:
- receiver: '*cloud.google.com/go/pubsub.Topic'
- name: Publish
advice:
- prepend-statements:
imports:
tracing: gopkg.in/DataDog/dd-trace-go.v1/contrib/cloud.google.com/go/pubsub.v1/internal/tracing
template: |-
{{- $topic := .Function.Receiver -}}
{{- $ctx := .Function.Argument 0 -}}
{{- $msg := .Function.Argument 1 -}}
{{- $publishResult := .Function.Result 0 -}}
__dd_traceMsg := &tracing.Message{
ID: {{ $msg }}.ID,
Data: {{ $msg }}.Data,
OrderingKey: {{ $msg }}.OrderingKey,
Attributes: {{ $msg }}.Attributes,
DeliveryAttempt: {{ $msg }}.DeliveryAttempt,
PublishTime: {{ $msg }}.PublishTime,
}
__dd_ctx, __dd_closeSpan := tracing.TracePublish({{ $ctx }}, {{ $topic }}, __dd_traceMsg)
{{ $ctx }} = __dd_ctx
{{ $msg }}.Attributes = __dd_traceMsg.Attributes
defer func() {
{{ $publishResult }}.DDCloseSpan = __dd_closeSpan
}()
- id: PublishResult.Get
join-point:
function-body:
function:
- receiver: '*cloud.google.com/go/internal/pubsub.PublishResult'
- name: Get
advice:
- prepend-statements:
template: |-
{{- $publishResult := .Function.Receiver -}}
{{- $serverID := .Function.Result 0 -}}
{{- $err := .Function.Result 1 -}}
defer func() {
if {{ $publishResult }}.DDCloseSpan != nil {
{{ $publishResult }}.DDCloseSpan({{ $serverID }}, {{ $err }})
}
}()
Loading

0 comments on commit 3094530

Please sign in to comment.