Skip to content

Commit 351c1b6

Browse files
Fixed merge conflict
2 parents 8fa9738 + 301ffb5 commit 351c1b6

File tree

23 files changed

+486
-347
lines changed

23 files changed

+486
-347
lines changed

src/content/docs/apm/agents/net-agent/configuration/net-agent-configuration.mdx

+16-1
Original file line numberDiff line numberDiff line change
@@ -3554,6 +3554,7 @@ There are three main sub-features:
35543554
2. Log forwarding: When enabled, the agent will capture log data and send it to New Relic.
35553555
* Context data (via [`AddCustomAttribute`](/docs/apm/agents/net-agent/net-agent-api/itransaction/#addcustomattribute)): When enabled, the agent will capture and forward any custom log attributes. The `include` and `exclude` elements are comma-separated lists of attribute names to include or exclude, following the [same rules](/docs/apm/agents/net-agent/attributes/enable-disable-attributes-net/#attruls) as other agent attribute configuration. They're both empty by default, which results in all log context data being captured and forwarded.
35563556
* Log-level filtering: When configured with one or more log levels in a comma-separated list, the agent will prevent messages at those levels from being captured and forwarded.
3557+
* Labels: When enabled, the agent adds custom labels to agent-forwarded logs. You can use the `exclude` attribute, which is a case-insensitive, comma-separated list of label names. By default, the agent adds custom labels when the `exclude` attribute is empty.
35573558
3. Local log decoration: When enabled, your existing logs will be decorated with metadata which links logs with other New Relic data, such as errors.
35583559

35593560
For more details, see [our docs on using .NET agent logs in context](/docs/logs/logs-context/net-configure-logs-context-all).
@@ -3563,6 +3564,7 @@ For more details, see [our docs on using .NET agent logs in context](/docs/logs/
35633564
<metrics enabled="true" />
35643565
<forwarding enabled="true" maxSamplesStored="10000" logLevelDenyList="">
35653566
<contextData enabled="false" include="" exclude="" />
3567+
<labels enabled="false" exclude="" />
35663568
</forwarding>
35673569
<localDecorating enabled="false" />
35683570
</applicationLogging>
@@ -3579,6 +3581,8 @@ NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CONTEXT_DATA_INCLUDE="myCustomAttribute
35793581
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_CONTEXT_DATA_EXCLUDE="myCustomAttribute2, myOtherCustomAttributeMoreSpecificName"
35803582
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_MAX_SAMPLES_STORED=10000
35813583
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LOG_LEVEL_DENYLIST="debug, warn"
3584+
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_ENABLED=true
3585+
NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_EXCLUDE="label1, label2"
35823586
NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED=true
35833587
```
35843588

@@ -3661,6 +3665,17 @@ The `applicationLogging` element supports the following attributes and sub-eleme
36613665
The include and exclude lists follow the [same precedence rules as other agent attributes configuration](/docs/apm/agents/net-agent/attributes/enable-disable-attributes-net/#attruls).
36623666
</Collapser>
36633667

3668+
<Collapser
3669+
id="labels"
3670+
title="labels (tags)"
3671+
>
3672+
Use this sub-element, which is a child of the `forwarding` element, to configure adding your [labels (tags)](/docs/apm/agents/net-agent/configuration/net-agent-configuration/#labels-tags) to agent-forwarded logs, in agent versions 10.34.0 and higher.
3673+
3674+
Set the `enabled` attribute to `true` to enable adding your labels to agent-forwarded logs. You can also use the environment variable `NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_ENABLED`. The default value is `false`.
3675+
3676+
The `exclude` attribute is a case-insensitive, comma-separated list of label names to exclude when you enable labels. You can also use the environment variable `NEW_RELIC_APPLICATION_LOGGING_FORWARDING_LABELS_EXCLUDE`. The default value is an empty string, which means "exclude nothing". This attribute does not support wildcards or regex.
3677+
</Collapser>
3678+
36643679
<Collapser
36653680
id="localDecorating"
36663681
title="Local log decoration"
@@ -3870,4 +3885,4 @@ For .NET Core apps, you can configure the following settings in `appsettings.jso
38703885

38713886
<Callout variant="important">
38723887
For [ASP.NET Core apps](https://asp.net/), the .NET Agent will read from `appsettings.{environment}.json` if you set the `ASPNETCORE_ENVIRONMENT` variable.
3873-
</Callout>
3888+
</Callout>

src/content/docs/apm/agents/net-agent/net-agent-api/net-agent-api.mdx

+66-3
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,7 @@ The following list contains the different calls you can make with the API, inclu
23342334

23352335
### Description
23362336

2337-
Sets the name of the current transaction. Before you use this call, ensure you understand the implications of [metric grouping issues](/docs/agents/manage-apm-agents/troubleshooting/metric-grouping-issues).
2337+
Set a custom transaction name, to be appended after an initial prefix (`WebTransaction` or `OtherTransaction`) based on the type of the current transaction. Before you use this call, ensure you understand the implications of [metric grouping issues](/docs/agents/manage-apm-agents/troubleshooting/metric-grouping-issues).
23382338

23392339
If you use this call multiple times within the same transaction, each call overwrites the previous call and the last call sets the name.
23402340

@@ -2392,8 +2392,71 @@ The following list contains the different calls you can make with the API, inclu
23922392

23932393
### Examples
23942394

2395+
This example shows use of this API in an ASP.NET Core MVC controller. A transaction is created automatically by the agent's instrumentation for ASP.NET Core. The first part of the transaction name will continue to be `WebTransaction`.
2396+
2397+
```cs
2398+
public class HomeController : Controller
2399+
{
2400+
2401+
public IActionResult Order(string product)
2402+
{
2403+
2404+
// The commented-out API call below is probably a bad idea and will lead to a metric grouping issue (MGI)
2405+
// because too many transaction names will be created. Don't do this.
2406+
//NewRelic.Api.Agent.NewRelic.SetTransactionName("Other", $"ProductOrder-{product}");
2407+
2408+
// Do this instead if you want to record request-specific data about this MVC endpoint
2409+
var tx = NewRelic.Api.Agent.NewRelic.GetAgent().CurrentTransaction;
2410+
tx.AddCustomAttribute("productName", product);
2411+
2412+
// The default transaction name at this point will be: WebTransaction/MVC/Home/Order
2413+
2414+
// Set custom transaction name
2415+
NewRelic.Api.Agent.NewRelic.SetTransactionName("Other", "OrderProduct");
2416+
2417+
// Transaction name is now: WebTransaction/Other/OrderProduct
2418+
2419+
return View();
2420+
}
2421+
}
2422+
```
2423+
2424+
This example shows use of this API in a console application. Note the `[Transaction]` custom instrumentation attribute, which is necessary to create a transaction for the example method. The first part of the transaction name will continue to be `OtherTransaction`.
2425+
23952426
```cs
2396-
NewRelic.Api.Agent.NewRelic.SetTransactionName("Other", "MyTransaction");
2427+
using NewRelic.Api.Agent;
2428+
2429+
namespace SetApplicationNameConsoleExample
2430+
{
2431+
internal class Program
2432+
{
2433+
static void Main(string[] args)
2434+
{
2435+
Console.WriteLine("Hello, World!");
2436+
2437+
var start = DateTime.Now;
2438+
while (DateTime.Now - start < TimeSpan.FromMinutes(2))
2439+
{
2440+
DoSomething();
2441+
Thread.Sleep(TimeSpan.FromSeconds(5));
2442+
}
2443+
}
2444+
2445+
[Transaction] // Attribute-based custom instrumentation to create a transaction for this method
2446+
static void DoSomething()
2447+
{
2448+
Console.WriteLine("Doing something: " + Guid.NewGuid().ToString());
2449+
2450+
// Transaction name from default naming at this point is: OtherTransaction/Custom/SetApplicationNameConsoleExample.Program/DoSomething
2451+
2452+
NewRelic.Api.Agent.NewRelic.SetTransactionName("Console", "MyCustomTransactionName");
2453+
2454+
// Transaction name at this point is: OtherTransaction/Console/MyCustomTransactionName
2455+
2456+
// Note, however, that this transaction will still have a child segment (span) named "SetApplicationNameConsoleExample.Program.DoSomething"
2457+
}
2458+
}
2459+
}
23972460
```
23982461
</Collapser>
23992462

@@ -2420,7 +2483,7 @@ The following list contains the different calls you can make with the API, inclu
24202483

24212484
### Description
24222485

2423-
Sets the URI of the current transaction. The URI appears in the `request.uri` attribute of [transaction traces](/docs/apm/transactions/transaction-traces/transaction-traces) and [transaction events](/docs/using-new-relic/metrics/analyze-your-metrics/data-collection-metric-timeslice-event-data), and it also can affect transaction naming.
2486+
Set the URI of the current transaction. The URI appears in the `request.uri` attribute of [transaction traces](/docs/apm/transactions/transaction-traces/transaction-traces) and [transaction events](/docs/using-new-relic/metrics/analyze-your-metrics/data-collection-metric-timeslice-event-data), and it also can affect transaction naming.
24242487

24252488
If you use this call multiple times within the same transaction, each call overwrites the previous call. The last call sets the URI.
24262489

0 commit comments

Comments
 (0)