Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Telemetry Events #226

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions lib/oidcc/provider_configuration.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
defmodule Oidcc.ProviderConfiguration do
use TelemetryRegistry

telemetry_event(%{
event: [:oidcc, :load_configuration, :start],
description: "Emitted at the start of loading the provider configuration",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string()}"
})

telemetry_event(%{
event: [:oidcc, :load_configuration, :stop],
description: "Emitted at the end of loading the provider configuration",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string()}"
})

telemetry_event(%{
event: [:oidcc, :load_configuration, :exception],
description: "Emitted at the end of loading the provider configuration",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string()}"
})

telemetry_event(%{
event: [:oidcc, :load_jwks, :start],
description: "Emitted at the start of loading the provider jwks",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{jwks_uri: :uri_string.uri_string()}"
})

telemetry_event(%{
event: [:oidcc, :load_jwks, :stop],
description: "Emitted at the end of loading the provider jwks",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{jwks_uri: :uri_string.uri_string()}"
})

telemetry_event(%{
event: [:oidcc, :load_jwks, :exception],
description: "Emitted at the end of loading the provider jwks",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{jwks_uri: :uri_string.uri_string()}"
})

@moduledoc """
Tooling to load and parse Openid Configuration

## Telemetry

#{telemetry_docs()}
"""

use Oidcc.RecordStruct,
Expand Down
90 changes: 90 additions & 0 deletions lib/oidcc/token.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,96 @@
defmodule Oidcc.Token do
use TelemetryRegistry

telemetry_event(%{
event: [:oidcc, :request_token, :start],
description: "Emitted at the start of requesting a code token",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :request_token, :stop],
description: "Emitted at the end of requesting a code token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :request_token, :exception],
description: "Emitted at the end of requesting a code token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :refresh_token, :start],
description: "Emitted at the start of refreshing a token",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :refresh_token, :stop],
description: "Emitted at the end of refreshing a token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :refresh_token, :exception],
description: "Emitted at the end of refreshing a token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :jwt_profile_token, :start],
description: "Emitted at the start of exchaning a JWT profile token",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :jwt_profile_token, :stop],
description: "Emitted at the end of exchaning a JWT profile token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :jwt_profile_token, :exception],
description: "Emitted at the end of exchaning a JWT profile token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :client_credentials, :start],
description: "Emitted at the start of requesting a client credentials token",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :client_credentials, :stop],
description: "Emitted at the end of requesting a client credentials token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :client_credentials, :exception],
description: "Emitted at the end of requesting a client credentials token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

@moduledoc """
Facilitate OpenID Code/Token Exchanges

## Telemetry

#{telemetry_docs()}
"""

use Oidcc.RecordStruct,
Expand Down
27 changes: 27 additions & 0 deletions lib/oidcc/token_introspection.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
defmodule Oidcc.TokenIntrospection do
use TelemetryRegistry

telemetry_event(%{
event: [:oidcc, :introspect_token, :start],
description: "Emitted at the start of introspecting the token",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :introspect_token, :stop],
description: "Emitted at the end of introspecting the token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :introspect_token, :exception],
description: "Emitted at the end of introspecting the token",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

@moduledoc """
OAuth Token Introspection

See https://datatracker.ietf.org/doc/html/rfc7662

## Telemetry

#{telemetry_docs()}
"""

use Oidcc.RecordStruct,
Expand Down
27 changes: 27 additions & 0 deletions lib/oidcc/userinfo.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
defmodule Oidcc.Userinfo do
use TelemetryRegistry

telemetry_event(%{
event: [:oidcc, :userinfo, :start],
description: "Emitted at the start of loading userinfo",
measurements: "%{system_time: non_neg_integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :userinfo, :stop],
description: "Emitted at the end of loading userinfo",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

telemetry_event(%{
event: [:oidcc, :userinfo, :exception],
description: "Emitted at the end of loading userinfo",
measurements: "%{duration: integer(), monotonic_time: integer()}",
metadata: "%{issuer: :uri_string.uri_string(), client_id: String.t()}"
})

@moduledoc """
OpenID Connect Userinfo

See https://openid.net/specs/openid-connect-core-1_0.html#UserInfo

## Telemetry

#{telemetry_docs()}
"""

alias Oidcc.ClientContext
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defmodule Oidcc.Mixfile do
defp deps() do
[
{:telemetry, "~> 1.2"},
{:telemetry_registry, "~> 0.3.1"},
{:jose, "~> 1.11"},
{:jsx, "~> 3.1"},
{:mock, "~> 0.3.8", only: :test},
Expand Down
7 changes: 6 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

{minimum_otp_vsn, "26"}.

{deps, [{telemetry, "~> 1.2"}, {jose, "~> 1.11"}, {meck, "~> 0.9.2"}]}.
{deps, [
{telemetry, "~> 1.2"},
{telemetry_registry, "~> 0.3.1"},
{jose, "~> 1.11"},
{meck, "~> 0.9.2"}
]}.

{project_plugins, [
%% Revert back to released version when this PR is merged & released:
Expand Down
48 changes: 48 additions & 0 deletions src/oidcc_provider_configuration.erl
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
%%%-------------------------------------------------------------------
%% @doc Tooling to load and parse Openid Configuration
%%
%% <h2>Records</h2>
%%
%% To use the record, import the definition:
%%
%% ```
%% -include_lib(["oidcc/include/oidcc_provider_configuration.hrl"]).
%% '''
%%
%% <h2>Telemetry</h2>
%%
%% See {@link 'Elixir.Oidcc.ProviderConfiguration'}
%% @end
%%%-------------------------------------------------------------------
-module(oidcc_provider_configuration).
Expand Down Expand Up @@ -36,7 +42,7 @@
%% </ul>

-type t() ::
#oidcc_provider_configuration{

Check warning on line 45 in src/oidcc_provider_configuration.erl

View workflow job for this annotation

GitHub Actions / Docs / Generate

internal inconsistency, please submit bug: "uri_string:uri_string" != "'.'"

Check warning on line 45 in src/oidcc_provider_configuration.erl

View workflow job for this annotation

GitHub Actions / Docs / Generate

internal inconsistency, please submit bug: "uri_string:uri_string" != "'.'"

Check warning on line 45 in src/oidcc_provider_configuration.erl

View workflow job for this annotation

GitHub Actions / Docs / Generate

internal inconsistency, please submit bug: "uri_string:uri_string" != "'.'"

Check warning on line 45 in src/oidcc_provider_configuration.erl

View workflow job for this annotation

GitHub Actions / Docs / Generate

internal inconsistency, please submit bug: "uri_string:uri_string" != "'.'"
issuer :: uri_string:uri_string(),
authorization_endpoint :: uri_string:uri_string(),
token_endpoint :: uri_string:uri_string() | undefined,
Expand Down Expand Up @@ -116,6 +122,48 @@

-define(DEFAULT_CONFIG_EXPIRY, timer:minutes(15)).

-telemetry_event(#{
event => [oidcc, load_configuration, start],
description => <<"Emitted at the start of loading the provider configuration">>,
measurements => <<"#{system_time => non_neg_integer()}">>,
metadata => <<"#{issuer => uri_string:uri_string()}">>
}).

-telemetry_event(#{
event => [oidcc, load_configuration, stop],
description => <<"Emitted at the end of loading the provider configuration">>,
measurements => <<"#{duration => integer(), monotonic_time => integer()}">>,
metadata => <<"#{issuer => uri_string:uri_string()}">>
}).

-telemetry_event(#{
event => [oidcc, load_configuration, exception],
description => <<"Emitted at the end of loading the provider configuration">>,
measurements => <<"#{duration => integer(), monotonic_time => integer()}">>,
metadata => <<"#{issuer => uri_string:uri_string()}">>
}).

-telemetry_event(#{
event => [oidcc, load_jwks, start],
description => <<"Emitted at the start of loading the provider jwks">>,
measurements => <<"#{system_time => non_neg_integer()}">>,
metadata => <<"#{jwks_uri => uri_string:uri_string()}">>
}).

-telemetry_event(#{
event => [oidcc, load_jwks, stop],
description => <<"Emitted at the end of loading the provider jwks">>,
measurements => <<"#{duration => integer(), monotonic_time => integer()}">>,
metadata => <<"#{jwks_uri => uri_string:uri_string()}">>
}).

-telemetry_event(#{
event => [oidcc, load_jwks, exception],
description => <<"Emitted at the end of loading the provider jwks">>,
measurements => <<"#{duration => integer(), monotonic_time => integer()}">>,
metadata => <<"#{jwks_uri => uri_string:uri_string()}">>
}).

%% @doc Load OpenID Configuration into a {@link oidcc_provider_configuration:t()} record
%%
%% <h2>Examples</h2>
Expand Down
Loading
Loading