WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 705a2bf

Browse files
Worker instrumentation (#3195)
* Updating worker instrumentation.
1 parent 81b2eb1 commit 705a2bf

25 files changed

+489
-335
lines changed
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System.Collections.Generic;
5+
46
namespace Microsoft.Azure.Functions.Worker
57
{
68
internal sealed class DefaultTraceContext : TraceContext
79
{
8-
public DefaultTraceContext(string traceParent, string traceState)
10+
public DefaultTraceContext(string traceParent, string traceState, IReadOnlyDictionary<string, string> attributes)
911
{
1012
TraceParent = traceParent;
1113
TraceState = traceState;
14+
Attributes = attributes;
1215
}
1316

1417
public override string TraceParent { get; }
1518

1619
public override string TraceState { get; }
20+
21+
public override IReadOnlyDictionary<string, string> Attributes { get; }
1722
}
1823
}

src/DotNetWorker.Core/Context/TraceContext.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System.Collections.Generic;
5+
using System.Collections.Immutable;
6+
47
namespace Microsoft.Azure.Functions.Worker
58
{
69
/// <summary>
@@ -17,5 +20,10 @@ public abstract class TraceContext
1720
/// Gets the state data.
1821
/// </summary>
1922
public abstract string TraceState { get; }
23+
24+
/// <summary>
25+
/// Gets the attributes associated with the trace.
26+
/// </summary>
27+
public virtual IReadOnlyDictionary<string, string> Attributes => ImmutableDictionary<string, string>.Empty;
2028
}
2129
}

src/DotNetWorker.Core/Diagnostics/ActivityExtensions.cs

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/DotNetWorker.Core/Diagnostics/FunctionActivitySourceFactory.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/DotNetWorker.Core/Diagnostics/FunctionInvocationScope.cs

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
namespace Microsoft.Azure.Functions.Worker.Diagnostics
55
{
66
internal enum OpenTelemetrySchemaVersion
77
{
8-
v1_17_0
8+
V1_17_0,
9+
V1_37_0
910
}
1011
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
4+
using System.Collections.Generic;
5+
using System.Diagnostics;
6+
7+
namespace Microsoft.Azure.Functions.Worker.Diagnostics;
8+
9+
/// <summary>
10+
/// Provides methods for telemetry data collection related to function invocations.
11+
/// </summary>
12+
/// <remarks>This interface defines methods to retrieve telemetry attributes and manage the activity lifecycle for
13+
/// function invocations, enabling detailed monitoring and diagnostics.</remarks>
14+
internal interface IFunctionTelemetryProvider
15+
{
16+
/// <summary>
17+
/// Returns the attributes to be applied to the Scope for this invocation.
18+
/// </summary>
19+
IEnumerable<KeyValuePair<string, object>> GetScopeAttributes(FunctionContext ctx);
20+
21+
/// <summary>
22+
/// Returns the attributes to be applied to the Activity for this invocation.
23+
/// </summary>
24+
IEnumerable<KeyValuePair<string, object>> GetTagAttributes(FunctionContext ctx);
25+
26+
/// <summary>
27+
/// Starts the Activity for this invocation.
28+
/// </summary>
29+
Activity? StartActivityForInvocation(FunctionContext ctx);
30+
}

0 commit comments

Comments
 (0)