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

Add set_secure_random_hex #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ckiickA
Copy link

@ckiickA ckiickA commented Nov 19, 2015

Create a random hexadecimal string. Very useful for making trace-ids in X-B3-* headers for zipkin.

@agentzh
Copy link
Member

agentzh commented Nov 23, 2015

@ckiickA Have you looked at the existing set_secure_random_* directives?

See https://github.com/openresty/set-misc-nginx-module#set_secure_random_alphanum for example.

@ckiickA
Copy link
Author

ckiickA commented Nov 23, 2015

I have. However, there's no way to restrict the string generated to just hex digits. The Zipkin spec says traceid's are random hexadecimal 64 bit numbers. I attempted to use get_random and hex_encode, but hex_encode just gives the ascii codes of the digits.

@agentzh
Copy link
Member

agentzh commented Nov 23, 2015

@ckiickA Hmm, maybe you should use the ngx_lua module for such special requirements instead. Otherwise this simple ngx_set_misc module would keep growing forever, which is a bad thing IMHO :)

@ckiickA
Copy link
Author

ckiickA commented Nov 23, 2015

Not an option for our environment. I can use a custom patch for now. Just
thought you might find it useful.
Producing a random hex string doesn't seem that much of a special
requirement to me. I was surprised that none of the existing modules could
do it.
Anyway, do what you want with the PR. Just trying to give back.

On Mon, Nov 23, 2015 at 9:29 AM, Yichun Zhang [email protected]
wrote:

@ckiickA https://github.com/ckiickA Hmm, maybe you should use the
ngx_lua module for such special requirements instead. Otherwise this simple
ngx_set_misc module would keep growing forever, which is a bad thing IMHO :)


Reply to this email directly or view it on GitHub
#28 (comment)
.

Chris J. Kiick
Senior Performance Engineer, Atlassian
[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants