Skip to content

Commit

Permalink
Add UserId
Browse files Browse the repository at this point in the history
  • Loading branch information
borisermakof committed May 2, 2024
1 parent 6556ca3 commit 62cc92c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@ public class DigmaConfigurationOptions
private const string DEFAULT_DEPLOYMENT_ENV_ENV_VAR = "DEPLOYMENT_ENV";
private const string DEFAULT_DIGMA_ENV_ENV_VAR = "DIGMA_ENV";
private const string DEFAULT_DIGMA_ENV_ID_VAR = "DIGMA_ENV_ID";
private const string DEFAULT_DIGMA_USER_ID_VAR = "DIGMA_USER_ID";

public string? NamespaceRoot { get; set; } = null;
public string? Environment { get; set; } = null;

public string? UserId { get; set; } = "";
public string? EnvironmentId { get; set; }
public string CommitIdEnvVariable { get; set; } = DEFAULT_COMMIT_ENV_VAR;
[Obsolete("Please use DigmaEnvironmentEnvVariable")]
public string EnvironmentEnvVariable { get; set; } = DEFAULT_DEPLOYMENT_ENV_ENV_VAR;
public string DigmaEnvironmentEnvVariable { get; set; } = DEFAULT_DIGMA_ENV_ENV_VAR;
public string DigmaEnvironmentIdVariable { get; set; } = DEFAULT_DIGMA_ENV_ID_VAR;

public string DigmaUserIdVariable { get; set; } = DEFAULT_DIGMA_USER_ID_VAR;
public string? CommitId { get; set; } = null;
public string? SpanMappingPattern { get; set; } = "";
public string? SpanMappingReplacement { get; set; } = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ public static ResourceBuilder AddDigmaAttributes(this ResourceBuilder builder,
{
options.Environment = hostName + "[local]";
}

if (string.IsNullOrWhiteSpace(options.UserId))
{
options.UserId = Environment.GetEnvironmentVariable(options.DigmaUserIdVariable) ?? "";
}

builder.AddAttributes(new[]
{
new KeyValuePair<string, object>("digma.user.id", options.UserId),
new KeyValuePair<string, object>("digma.environment.id", options.EnvironmentId),
new KeyValuePair<string, object>("digma.environment", options.Environment),
new KeyValuePair<string, object>("paths.working_directory", workingDirectory),
Expand Down

0 comments on commit 62cc92c

Please sign in to comment.