Skip to content

Commit

Permalink
app and client tracing params (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
t-ronmoneta authored Apr 8, 2024
1 parent 08bfd97 commit cff21e8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion azkustoingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Ingestion struct {

withoutEndpointCorrection bool
customIngestConnectionString *azkustodata.ConnectionStringBuilder
applicationForTracing string
clientVersionForTracing string
}

// New is a constructor for Ingestion.
Expand All @@ -44,6 +46,9 @@ func New(kcsb *azkustodata.ConnectionStringBuilder, options ...Option) (*Ingesti
newKcsb.DataSource = addIngestPrefix(newKcsb.DataSource)
kcsb = &newKcsb
}
clientDetails := azkustodata.NewClientDetails(kcsb.ApplicationForTracing, kcsb.UserForTracing)
i.applicationForTracing = clientDetails.ApplicationForTracing()
i.clientVersionForTracing = clientDetails.ClientVersionForTracing()

client, err := azkustodata.New(kcsb)
if err != nil {
Expand All @@ -63,7 +68,7 @@ func newFromClient(client QueryClient, i *Ingestion) (*Ingestion, error) {
i.client = client
i.mgr = mgr

fs, err := queued.New(i.db, i.table, mgr, client.HttpClient(), queued.WithStaticBuffer(i.bufferSize, i.maxBuffers))
fs, err := queued.New(i.db, i.table, mgr, client.HttpClient(), i.applicationForTracing, i.clientVersionForTracing, queued.WithStaticBuffer(i.bufferSize, i.maxBuffers))
if err != nil {
mgr.Close()
client.Close()
Expand Down
4 changes: 4 additions & 0 deletions azkustoingest/internal/properties/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ type Ingestion struct {
Additional Additional `json:"AdditionalProperties"`
// TableEntryRef points to the staus table entry used to report the status of this ingestion.
TableEntryRef StatusTableDescription `json:"IngestionStatusInTable,omitempty"`
// ApplicationForTracing is the application name that is used for tracing.
ApplicationForTracing string `json:",omitempty"`
// ClientVersionForTracing is the client version that is used for tracing.
ClientVersionForTracing string `json:",omitempty"`
}

// Additional is additional properites.
Expand Down
9 changes: 8 additions & 1 deletion azkustoingest/internal/queued/queued.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type Ingestion struct {

bufferSize int
maxBuffers int

applicationForTracing string
clientVersionForTracing string
}

// Option is an optional argument to New().
Expand All @@ -80,7 +83,7 @@ func WithStaticBuffer(bufferSize int, maxBuffers int) Option {
}

// New is the constructor for Ingestion.
func New(db, table string, mgr *resources.Manager, http *http.Client, options ...Option) (*Ingestion, error) {
func New(db, table string, mgr *resources.Manager, http *http.Client, applicationForTracing string, clientVersionForTracing string, options ...Option) (*Ingestion, error) {
i := &Ingestion{
db: db,
table: table,
Expand All @@ -94,6 +97,8 @@ func New(db, table string, mgr *resources.Manager, http *http.Client, options ..
options *azblob.UploadFileOptions) (azblob.UploadFileResponse, error) {
return client.UploadFile(ctx, container, blob, file, options)
},
applicationForTracing: applicationForTracing,
clientVersionForTracing: clientVersionForTracing,
}

for _, opt := range options {
Expand Down Expand Up @@ -246,6 +251,8 @@ func (i *Ingestion) Blob(ctx context.Context, from string, fileSize int64, props
}

props.Ingestion.RetainBlobOnSuccess = !props.Source.DeleteLocalSource
props.Ingestion.ApplicationForTracing = i.applicationForTracing
props.Ingestion.ClientVersionForTracing = i.clientVersionForTracing

err := CompleteFormatFromFileName(&props, from)
if err != nil {
Expand Down

0 comments on commit cff21e8

Please sign in to comment.